package models;

import play.*;
import play.db.jpa.*;

import javax.persistence.*;

import java.lang.reflect.Array;
import java.util.*;

@Entity
/***
 * this is the question class where the question is created for a certain exercise
 * @author hadeer
 *
 */
public class Question extends Model {
	public String theQuestion;
	public int marks;
	// @ElementCollection
	@OneToMany(mappedBy = "myQuestion", cascade = CascadeType.ALL)
	private List<Choice> myChoices;
	@ManyToOne
	@JoinColumn(name = "questionInEexercise")
	public Exercise myExercise;

	public String modelAnswer = null;// samar this is the model answer for the
										// question.
	public String comment;

	public Question(String question, int marks, long Eid) {
		this.theQuestion = question;
		this.marks = marks;
		this.myExercise = Exercise.findById(Eid);
		this.myChoices = new ArrayList<Choice>();

		save();
	}

	
	/***
	 * This method get the model answer for the question
	 * @author samar
	 *@param
	 */
	
	public String getModelAnswer() {
		return modelAnswer;
	}

	/***
	 * This method set the model answer for the question and save it in the data base
	 * @author samar
	 *@param string modelAnswer
	 */
	
	
	public void setModelAnswer(String modelAnswer) {
		this.modelAnswer = modelAnswer;
		this.save();
	}
/***
 * this method returns the question of the question
 * @author hadeer
 * @return
 */
	public String getTheQuestion() {
		return theQuestion;
	}
/***
 * this method sets the question with the given String
 * @author hadeer
 * @param theQuestion
 */
	public void setTheQuestion(String theQuestion) {
		this.theQuestion = theQuestion;
	}
/***
 * this method returns the list of choices of an exercise
 * @author hadeer
 * @return
 */
	public List<Choice> getMyChoices() {
		return myChoices;
	}
/***
 * this method sets the list of choices to the given list
 * @author hadeer
 * @param myChoices
 */
	public void setMyChoices(List<Choice> myChoices) {
		this.myChoices = myChoices;
	}
/***
 * this method returns the marks of the question
 * @author hadeer
 * @return
 */
	public int getMarks() {
		return marks;
	}
/***
 * this method sets the marks of the question to the given integer
 * @author hadeer
 * @param marks
 */
	public void setMarks(int marks) {
		this.marks = marks;
	}
/***
 * this method returns the comment of the question
 * @author hadeer
 * @return
 */
	public String getComment() {
		return comment;
	}
/***
 * this method sets the comment of the question to the String given
 * @author hadeer
 * @param comment
 */
	public void setComment(String comment) {
		this.comment = comment;
	}
/***
 * this method returns the exercise of the question
 * @author hadeer
 * @return
 */
	public Exercise getMyExercise() {
		return myExercise;
	}
/***
 * this method sets the exercise to the given exercise
 * @author hadeer
 * @param myExercise
 */
	public void setMyExercise(Exercise myExercise) {
		this.myExercise = myExercise;
	}

}
